#ifndef CSTRING_H
#define CSTRING_H


#ifdef __cplusplus
extern "C"
{
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <float.h>

typedef struct CString
{
	size_t cStringSpaceLength;
	size_t length;
	char* cString;
	
	struct CString* (*newCString)(const char*);
	int (*appendChar)(struct CString*, char);
	int (*appendString)(struct CString*, const char*);
	int (*appendCString)(struct CString*, const struct CString*);
	char* (*toCCharString)(const struct CString*);
	int (*getCharIndex)(const struct CString*, char);
	int (*getStringIndex)(const struct CString* cstring, const char*);
	char (*getCharWithIndex)(size_t);
	char* (*getStringWithIndex)(size_t);
	int (*countChar)(const struct CString*, char);
	int (*setCharValueWithIndex)(char, size_t);
	int (*setStringValueWithIndex)(const char*, size_t, size_t); 
	int (*insertCharWithIndex)(char, size_t);
	int (*insertStringWithIndex)(const char*, size_t);
	char (*popCharWithIndex)(size_t);
	char* (*popStringWithIndex)(size_t, size_t);
	char (*popCharWithChar)(char);
	char* (*popStringWithString)(const char*);
	char* (*slice)(const struct CString* cstring, size_t, size_t);
	char* (*sort)(const struct CString*);
	char** (*split)(const struct CString*, char splitChar, int resultOrder);
	int (*equalWithCString)(const struct CString*, const struct CString*);
	int (*empty)(const struct CString*);
	size_t (*size)(const struct CString*);
	size_t (*capacity)(const struct CString*);
	int (*recapacity)(const struct CString*, int);
	int (*freeCString)(struct CString**);
}CString, *CStringPointer;

CString* newCString(const char* rawString);

int appendChar(CString* cstring, char newChar);
int appendString(CString* cstring, const char* newString);
int appendCString(CString* cstring, const CString* newCString);

char* toCCharString(const CString* cstring);

int getCharIndex(const CString* cstring, char toFindChar);
int getStringIndex(const CString* cstring, const char* toFindSting);
char getCharWithIndex(size_t index);
char* getStringWithIndex(size_t index);

int countChar(const CString* cstring, char countChar);

int setCharValueWithIndex(char newChar, size_t index);
int setStringValueWithIndex(const char* newString, size_t startIndex, size_t endIndex); 

int insertCharWithIndex(char ch, size_t locationIndex);
int insertStringWithIndex(const char* newString, size_t locationIndex);

char popCharWithIndex(size_t index);
char* popStringWithIndex(size_t startIndex, size_t endIndex);
char popCharWithChar(char popChar);
char* popStringWithString(const char* string);

char* slice(const CString* cstring, size_t startIndex, size_t endIndex);

char* sort(const CString* cstring);

char** split(const CString* cstring, char splitChar, int resultOrder);

int equalWithCString(const CString* cstringA, const CString* cstringB);

int empty(const CString* cstring);
size_t size(const CString* cstring);
size_t capacity(const CString* cstring);
int recapacity(const CString* cstring, int deltaValue);

int freeCString(CString** cstring);




#ifdef __cplusplus
}
#endif

#endif
